package com.nix.web.databases.mapper.user;

import com.nix.web.databases.CurdFactory;
import com.nix.web.databases.pojo.user.*;
import com.nix.web.databases.pojo.word.Word;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhangpei
 * @Email zhangpe0312@qq.com
 * @day 2017/11/2 13:22
 * @Use
 */
@Repository
public interface UserMapper extends CurdFactory<User> {

    /**
     * 用户登陆方法 通过账户密码
     *
     * @param name
     * @param password
     * @return
     * @throws Exception
     */
    User login(@Param("name") String name, @Param("password") String password) throws Exception;

    /**
     * 通过账户登录
     *
     * @param name
     * @return
     * @throws Exception
     */
    User loginByName(String name) throws Exception;

    /**
     * 通过用户id和enable确定要查找的用户类型
     *
     * @param uid    用户id
     * @param enable 0为冻结了的用户 1为正常用户
     * @return
     */

    User getUserInformation(@Param("uid") Integer uid, @Param("enable") Integer enable) throws Exception;

    /**
     * 注册账号时用来绑定用户和用户信息的方法
     *
     * @param uid
     * @param infoid
     * @return
     * @throws Exception
     */
    int register(@Param("uid") Integer uid, @Param("infoid") Integer infoid) throws Exception;

    Integer getUserIdByEmail(String email);

    User getUserPermission(@Param("uid") Integer uid) throws Exception;

    void addRole(@Param("uid")Integer uid ,@Param("rid") Integer rid);
}
